#include <zenilib.h>
#include "Platform.h"

Vector2 Platform::firstPoint = Vector2(0, 0);

Platform::Platform(Vector2 pos_, Vector2 scale_, std::string texture_) :
	GameObject(pos_, scale_)
{
	addTexture(texture_);
	mass = 0.0f; //infinite
	inertia = 0.0f;
}

Platform::Platform(Vector2 pos_, std::string texture_) :
	GameObject(pos_, Vector2(0, 0))
{
	firstPoint = pos;
	addTexture(texture_);
	mass = 0.0f; //infinite
	inertia = 0.0f;
}

Platform::Platform(Platform &rhs) : 
	GameObject(rhs.pos, rhs.scale)
{
	addTexture(rhs.textures[0]);
	mass = 0.0f; //infinite
	inertia = 0.0f;
}

void Platform::setSecondPoint(Vector2 p)
{
	pos = (firstPoint + p) / 2;
	scale = Vector2(abs(firstPoint.x - p.x), abs(firstPoint.y - p.y));
	poly = Poly(pos - scale / 2, pos + scale / 2);
}